package com.zxhtom.application;

import com.github.zxhTom.csdnSdk.handler.Blog;
import com.github.zxhTom.csdnSdk.model.Article;
import com.github.zxhTom.csdnSdk.model.Result;
import com.github.zxhTom.csdnSdk.utils.TokenUtil;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.zxhtom.utils.HttpClientUtil;
import org.zxhtom.utils.MathUtil;


public class Csdn
{
    private static List<Article> list = new ArrayList();
    private static Blog blog = new Blog();
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    private static Integer dateKey = Integer.valueOf(0);
    static  {
        TokenUtil.getInstance().login("870775401@qq.com", "QQ15996779085");
    }

    public static void main(String[] args) {
        List<Integer> result = new ArrayList<Integer>();
        result.add(Integer.valueOf(11));
        result.add(Integer.valueOf(2));
        result.add(Integer.valueOf(3));
        result.add(Integer.valueOf(4));
        result.add(Integer.valueOf(5));
        List<Integer> integers = result.subList(0, 5);
        for (int i = 0; i < integers.size(); i++) {
            System.out.println("@@" + integers.get(i));
        }
    }


    public static void ttt() {
        Result result = blog.getArticleList();
        list = (List)result.getData();
        Thread t1 = new Thread(new Runnable()
        {
            public void run() {
                try {
                    for (int i = 0; i < 10; i++) {
                        i = 0;
                        Integer nowDateKey = Integer.valueOf(sdf.format(new Date()));
                        if (dateKey < nowDateKey) {
                            dateKey = nowDateKey;
                            list = ((List)blog.getArticleList().getData());
                        }
                        Integer random = MathUtil.getInstance().getRandom(Integer.valueOf(0), Integer.valueOf(list.size()));
                        System.out.println("���������������" + Thread.currentThread().getName() + "���������������������..");
                        String visitUrl = "";
                        if (random.intValue() >= 0 && random.intValue() < list.size()) {
                            visitUrl = "https:" + ((Article)list.get(random.intValue())).getUrl();
                        }
                        System.out.println("visit@@:" + visitUrl);
                        HttpClientUtil.getInstance().httpGet(visitUrl);
                        Thread.sleep(70000L);
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"t1");

        t1.start();
    }
}
